<template>
    <div>
        <a href="/Add">新增</a>
        姓名:<input type="text" v-model="ts.name">
        会员等级:
        <select v-model="ts.levelid">
            <option value="0">请选择</option>
            <option v-for="a in data" :value="a.memberLevelId">{{ a.memberLevelName }}</option>
        </select>
        状态:
        <select v-model="ts.state">
            <option :value="null">请选择</option>
            <option :value="true">开启</option>
            <option :value="false">关闭</option>
        </select>
        <input type="button" value="查询" @click="xx">
        <input type="button" value="重置" @click="xxx">
        <table class="table">
            <thead>
                <tr>
                    <td>编号</td>
                    <td>用户姓名</td>
                    <td>性别</td>
                    <td>手机号</td>
                    <td>会员等级</td>
                    <td>消费金额</td>
                    <td>消费次数</td>
                    <td>可用积分</td>
                    <td>可用余额</td>
                    <td>启用状态</td>
                    <td>创建时间</td>
                </tr>
            </thead>
            <tbody>
                <tr v-for="b in date">
                    <td>{{ b.memberId }}</td>
                    <td>{{ b.memberName }}</td>
                    <td>{{ b.sex==1?"男":"女" }}</td>
                    <td>{{ b.phone }}</td>
                    <td>{{ b.memberLevelName }}</td>
                    <td>{{ b.price }}</td>
                    <td>{{ b.num }}</td>
                    <td>{{ b.intation }}</td>
                    <td>{{ b.kPrice }}</td>
                    <td>{{ b.state?"开启":"关闭" }}</td>
                    <td>{{ moment(b.createDate).format("YYYY-MM-DD HH:MM:SS") }}</td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref,onMounted } from 'vue';
import axios from 'axios';
import moment from 'moment';
onMounted(()=>{
    getdate(),
    show()
})
const xx=()=>{
    show()
}
const xxx=()=>{
    ts.value={
        name:'',
        state:null,
        levelid:0
    }
    show()
}


const getdate=()=>{
    axios.get("https://localhost:7126/api/MemberLevel/GetMemberLevels").then(res=>{
        data.value=res.data
    })
}
const data=ref([{
    "memberLevelId": 0,
    "memberLevelName": ""
}])

const ts=ref({
    name:'',
    state:null,
    levelid:0
})
const show=()=>{
    axios.get("https://localhost:7126/api/Member/ShowMember",{params:ts.value}).then(res=>{
        date.value=res.data
    })
}
const date=ref([{
  "memberId": 0,
  "memberName": "",
  "sex": 0,
  "phone": "",
  "memberLevelId": 0,
  "price": 0,
  "num": 0,
  "intation": 0,
  "kPrice": 0,
  "state": false,
  "createDate": "",
  "memberLevelName": ""
}])
</script>

<style scoped>

</style>